import { createSlice,createAsyncThunk } from "@reduxjs/toolkit";
import * as API from "../api/http"

let initialState={
   shoplist:[]
}

const crmslice = createSlice({
  name: "crmslice",
  initialState,
  reducers: {
    shoplist(state,action){
        state.shoplist = action.payload;
    }
    // addshoplist(state,action){
    //     state.shoplist.push(action.payload);    
    // },
    // emitshoplist(state,action){
    //     let index=
    // }

  },
});

export const asyncFn = crmslice.actions;
export default crmslice.reducer;

export const async_shoplist=createAsyncThunk("async_shoplist",
  async(_,store)=>{
    let res=await API.getShoplist()
    store.dispatch(asyncFn.shoplist(res))
  }
)
